import 'babel-polyfill'
import Vue from 'vue'
import HighCharts from 'highcharts'
import HighchartsVue from 'highcharts-vue'
import App from './App'
import router from './router'
import store from './store'
import ViewUI from 'view-design'
import i18n from '@/locale'
import config from '@/config'
import importDirective from '@/directive'
import { directive as clickOutside } from 'v-click-outside-x'
import installPlugin from '@/plugin'
import './index.less'
import '@/assets/icons/iconfont.css'

import { TablePage } from '_c/tables'

// echarts 主题
import './assets/echarts-theme'

// 全局filter
import filters from './libs/filter'

import Cookies from 'js-cookie'
import highcharts3d from 'highcharts/highcharts-3d'
import HighchartsNoData from 'highcharts/modules/no-data-to-display'
import HighchartsMore from 'highcharts/highcharts-more'
import SolidGauge from 'highcharts/modules/solid-gauge'
import HeatMap from 'highcharts/modules/heatmap'
import Cylinder from 'highcharts/modules/cylinder'
import Funnel3d from 'highcharts/modules/funnel3d'
import Bullet from 'highcharts/modules/bullet'

/**
 * FileUpload
 * 文件上传，目前只用来做图片上传
 * */
import { FileUpload } from '_c/file-upload'
Vue.use(HighchartsVue)
highcharts3d(HighCharts)
HighchartsNoData(HighCharts)
HighchartsMore(HighCharts)
SolidGauge(HighCharts)
HeatMap(HighCharts)
Cylinder(HighCharts)
Funnel3d(HighCharts)
Bullet(HighCharts)
HighCharts.setOptions({
  credits: {
    enabled: false
  },
  colors: config.chartTheme,
  loading: {
    labelStyle: {
      color: '#009cc3'
    },
    style: {
      backgroundColor: 'rgba(33, 40, 72,.5)'
    }
  },
  lang: {
    noData: '暂无数据'
  },
  noData: {
    style: {
      color: '#ffffff'
    }
  }
})
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})
Object.defineProperty(Vue.prototype, '$Cookies', { value: Cookies })

Vue.use(ViewUI, {
  i18n: (key, value) => i18n.t(key, value),
  capture: false
})
Vue.use(TablePage)
Vue.use(FileUpload)
/**
 * @description 注册admin内置插件
 */
installPlugin(Vue)
/**
 * @description 生产环境关掉提示
 */
Vue.config.productionTip = false
/**
 * @description 全局注册应用配置
 */
Vue.prototype.$config = config
/**
 * 注册指令
 */
importDirective(Vue)
Vue.directive('clickOutside', clickOutside)

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  i18n,
  store,
  render: h => h(App)
})
